<?php

namespace app\admin\model;
use app\lib\FileDB;
class SupplyCompany extends FileDB
{
    //添加
    public static function add($data){
        $data['date_time'] = date('Y-m-d H:i:s');
        $result = self::table('supply_company')->insert($data);
        return $result;
    }
    //编辑
    public static function edit($data){
        $result = self::table('supply_company')->update($data);
        return $result;
    }
    //删除
    public static function del($id){
        return self::table('supply_company')->delete($id);
    }
    //列表
    public static function list($page){
        $perpage = 10;
        $list = self::table('supply_company')->selectLimit($perpage * ($page - 1),$perpage);
        $total = self::table('supply_company')->count();
        $data = [
            'total' => $total,
            'current' => $page,
            'perpage' => $perpage,
            'data' =>  $list
        ];
        return $data;
    }
    //列表
    public static function getList(){
        return self::table('supply_company')->order('id desc')->select();
    }

    //获取详情
    public static function detail($id){
        return self::table('supply_company')->find($id);
    }
}